//
//  CATransform3D+Extension.swift
//  Social
//
//  Created by 李响 on 2019/7/30.
//  Copyright © 2019 shengsheng. All rights reserved.
//

import UIKit

public func CATransform3DMakePerspective(_ center: CGPoint, _ disZ: CGFloat) -> CATransform3D {
    let transToCenter = CATransform3DMakeTranslation(-center.x, -center.y, 0)
    let transBack = CATransform3DMakeTranslation(center.x, center.y, 0)
    var scale = CATransform3DIdentity
    scale.m34 = -1.0 / disZ
    return CATransform3DConcat(CATransform3DConcat(transToCenter, scale), transBack)
}

public func CATransform3DPerspect(_ t: CATransform3D, center: CGPoint, disZ: CGFloat) -> CATransform3D {
    return CATransform3DConcat(t, CATransform3DMakePerspective(center, disZ))
}
